package com.java.base.exercise.current;

import java.sql.Time;
import java.util.concurrent.TimeUnit;

/**
 * @Author RenPu
 * @Date 2021/8/31 17:13
 * @Version 1.0
 * @Description:
 **/
public class Thread_Join {

    public static void main(String[] args) {


        Thread main = Thread.currentThread();


        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    main.interrupt();
                    TimeUnit.SECONDS.sleep(5);
                    System.out.println(Thread.currentThread().getName() + "执行完成！！！！！");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                    //thread.interrupt();
                }
            }
        }, "thread_1");
        thread.start();
        System.out.println("等待子线程运行结束！！！！");
        try {
            thread.join();
        } catch (InterruptedException e) {
            System.out.println(Thread.currentThread().getName() + "：" + "发生了异常");
            thread.interrupt();
        }

        System.out.println("子线程运行结束 over !!!!!");
    }


}
